package com.example.video

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.example.base.mvvm.BaseActivity
import com.example.video.databinding.ActivityDetailBinding

@Route(path = "/app/DetailActivity")
class DetailActivity : BaseActivity<ActivityDetailBinding,XqViewModel>() {
    @Autowired
    @JvmField
    var goodsId = 1

    var img = ""//动画效果

    override fun initView() {
        ARouter.getInstance().inject(this)
        viewModel.xq(goodsId,"normal")

        binding.addCar.setOnClickListener {
            viewModel.addCar(1,goodsId.toString(),goodsId)
        }
        binding.toCar.setOnClickListener {
            ARouter.getInstance().build("/app/CarActivity").navigation()
        }
    }

    override fun initData() {
        viewModel.xqSuccess.observe(this){
            if(it.code==200){
                binding.detailName.text = it.data.productInfo.storeName
                img = it.data.productInfo.image
            }
        }
        viewModel.addSuccess.observe(this){
            ToastUtils.showLong(it.message)
        }
    }

    override fun getViewModel(): Class<XqViewModel> {
        return XqViewModel::class.java
    }

    override fun getLayout(): Int {
        return R.layout.activity_detail
    }

}